# 导包
import unittest

from parameterized import parameterized

from api.login_api import LoginApi

from utils import read_info


# 定义测试类
class TestLogin(unittest.TestCase):
    # 定义测试方法
    @parameterized.expand(read_info())
    def test_login(self, case_name, user_data, expect_result):
        print(case_name, user_data, expect_result)

        # 发送post请求
        resp = LoginApi.login(json=user_data)
        # 获取响应体的json内容
        result = resp.json()
        print(result)
        # 断言
        self.assertEqual(expect_result.get('resp_code'), resp.status_code)
        self.assertEqual(expect_result.get('success'), result.get('success'))
        self.assertEqual(expect_result.get('code'), result.get('code'))
        self.assertEqual(expect_result.get('msg'), result.get('message'))
